package com.wuye.util;

import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class MyBatisSessionFactory 
{
	private static SqlSessionFactory sessionFactory;
	private static Reader reader;
	private static String configFile = "mybatis.xml";
	
	static
	{
		try 
		{
			reader = Resources.getResourceAsReader(configFile);
			sessionFactory = new SqlSessionFactoryBuilder().build(reader);
		}
		catch (Exception e) 
		{
			e.printStackTrace();
		}
		
	}
	
	public static SqlSession getSession()
	{
		return sessionFactory.openSession();
	}
	
	

}
